//
//  DemoArrayLoop.m
//  ocdemo
//
//  Created by JIENING ZHANG on 2019/4/5.
//  Copyright © 2019 JIENING ZHANG. All rights reserved.
//

#import "DemoArrayLoop.h"

@implementation DemoArrayLoop
+ (void)demoLogic {
    NSArray *month = @[
                       @"January",
                       @"February",
                       @"March",
                       @"April",
                       @"May",
                       @"June",
                       @"July",
                       @"August",
                       @"September",
                       @"October",
                       @"November",
                       @"December",
                       ];
    
    NSUInteger len=[month count];
    for(NSUInteger i=0; i<len; ++i){
        NSLog(@"DemoArrayLoop, for-index, %ld, %@", index, month[i]);
    }
    
    NSUInteger index=0;
    for(NSString *str in month) {
        NSLog(@"DemoArrayLoop, for-obj, %ld, %@", index, str);
        ++index;
    }
    
    [month enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        NSLog(@"DemoArrayLoop, enumerate, %ld, %@", idx, obj);
        
        if([obj isEqualToString:@"February"]) {
            *stop = YES;
        }
    }];
}
@end
